<?php
namespace app\nadmin\behavior;
use think\nadmin\Request;

/**
 * @explain 是否进行初始化操作 钩子行为
 */
class Isinit
{
    public function run()
    {
        $module = request()->module();
        $controller = request()->controller();  //当前访问控制器

        if($this->isInit() && strtolower($module."/".$controller) != "nadmin/sundry")
        {
            //初始化 --跳到 初始化页面
            $str = "<script>window.location.href='nadmin.php?s=nadmin/sundry/initpage'</script>";
            echo $str;
            die;
        }
    }
    protected function isInit()
    {

        if(file_exists(INITCONFIGPATH)){
            $data = include(INITCONFIGPATH);
            if(isset($data['agree'])){
                return $data['agree'];
            }else{
                return false;
            }
        }else{
            return false;
        }
    }
}